﻿<Window x:Class="ScrumFactory.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:SF="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
        xmlns:SF_Windows="clr-namespace:ScrumFactory.Windows"
        xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
        
        xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
        
        SnapsToDevicePixels="True"       
        
        x:Name="mainWindow"
        
        ResizeMode="NoResize"
      
        UseLayoutRounding="True"
                
        Style="{StaticResource FactoryMainWindow}"
              
        Title="{Binding WindowTitle}" 
            
        Icon="/Images/factory.ico"
        
        mc:Ignorable="d"         
        d:DesignHeight="314"
        d:DesignWidth="452">
    <Window.InputBindings>
        <KeyBinding Key="F5" Command="{Binding RefreshCommand}" />        
    </Window.InputBindings>

    <!--<Window.Resources>
        <Storyboard x:Key="buttonAnimIn">
            <DoubleAnimation Storyboard.TargetName="_back" Storyboard.TargetProperty="Opacity" To="0.2" Duration="00:00:00.5" />
        </Storyboard>
        <Storyboard x:Key="buttonAnimOut">
            <DoubleAnimation Storyboard.TargetName="_back" Storyboard.TargetProperty="Opacity" To="0" Duration="00:00:00.5" />
        </Storyboard>
    </Window.Resources>-->


    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>            
            <RowDefinition Height="*"/>                    
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="leftColumn" />                
            <ColumnDefinition Width="*"/>            
        </Grid.ColumnDefinitions>


        <SF_Windows:AlertMessage x:Name="alertMessage"
                                 Grid.Column="1" Grid.Row="0" Margin="0"                                                                   
                                 DataContext="{Binding AlertMessageViewModel}" VerticalAlignment="Bottom"/>
            

        <SF_Helpers:DockWindowContainer
                Grid.Column="1" Grid.Row="1"
                x:Name="dockWindowContainer"            
                ChildWindows="{Binding ChildWindows}"            
                ScrollDuration="50"                 
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

                <!-- PROJECT PANELS -->
                    <TabControl                                                                
                        Margin="0,0,0,0"
                        x:Name="projectPanels"                               
                        ItemsSource="{Binding ProjectPanels}"                    
                        SelectedItem="{Binding SelectedProjectTab}"
                        DisplayMemberPath="PanelName"                        
                        VerticalAlignment="Stretch">
                        <TabControl.ContentTemplate>
                            <DataTemplate>
                                <ContentPresenter Content="{Binding View}" />                                
                            </DataTemplate>
                        </TabControl.ContentTemplate>
                        
                        <TabControl.Style>
                            <Style TargetType="{x:Type TabControl}" BasedOn="{StaticResource WindowTabControl}">
                                <!--<Style.Triggers>
                                    <DataTrigger Binding="{Binding SelectedProject}" Value="{x:Null}">
                                        <Setter Property="TabControl.IsEnabled" Value="False"/>
                                        <Setter Property="TabControl.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>-->
                            </Style>
                        </TabControl.Style>
                    </TabControl>

            </SF_Helpers:DockWindowContainer>
        
            

        <!--<WrapPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">

            <Border CornerRadius="5" Padding="6" Cursor="Hand">
                <Border.Background>
                    <SolidColorBrush Color="White" Opacity="0.2"  />
                </Border.Background>
                <StackPanel Orientation="Vertical">                    
                    <TextBlock Text="Projetos recentes" Foreground="White" HorizontalAlignment="Center" FontSize="18"/>
                    <ListBox
                        Margin="0,5,0,0"
                        ItemsSource="{Binding RecentProjects}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock>
                                    <Hyperlink>
                                        <Run Text="{Binding ClientName}"/>
                                        <Run Text="{Binding ProjectName, StringFormat='{} - {0}'}"/>
                                        <Run Text="{Binding ProjectNumber, StringFormat='{}[{0}]'}"/>
                                    </Hyperlink>
                                </TextBlock>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>                
                
            </Border>

            <Border CornerRadius="5" Padding="10" Cursor="Hand">
                <Border.Background>
                    <SolidColorBrush Color="White" x:Name="_back" Opacity="0"  />
                </Border.Background>
                <StackPanel Orientation="Vertical">
                    <Image Source="/Images/Toolbar/postitView.png" Width="48" Height="48" HorizontalAlignment="Center"/>
                    <TextBlock Text="Ver meu dia" Foreground="White" HorizontalAlignment="Center" FontSize="18" Margin="0,10,0,0"/>
                </StackPanel>                
                <Border.Triggers>
                    <EventTrigger RoutedEvent="Button.MouseEnter">
                        <BeginStoryboard Storyboard="{StaticResource buttonAnimIn}" />
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Button.MouseLeave">
                        <BeginStoryboard Storyboard="{StaticResource buttonAnimOut}" />
                    </EventTrigger>
                </Border.Triggers>
            </Border>

        </WrapPanel>-->


        <Button             
            Command="{Binding SignInCommand}" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
            <TextBlock Text="{Binding SigninMenuText}" FontSize="48" Foreground="{StaticResource WindowTitleBarForegroundBrush}" Opacity="0.5" />
            <Button.Style>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource CleanButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsMemberSigned}" Value="True">
                            <Setter Property="Button.Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
                

        <!-- LEFT PANELS-->
        <Border x:Name="leftPanelsBorder"
                CornerRadius="0,0,0,0" Margin="0" BorderThickness="0,0,1,0" BorderBrush="LightGray"
                Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
                
                Background="{StaticResource DockPanelStripBackground}">
            <Grid>                
                <TabControl     
                x:Name="leftPanels" 
                TabStripPlacement="Right"                       
                Style="{StaticResource DockPanelTabControl}"
                ItemsSource="{Binding DockLeftPanels}"/>
                <ToggleButton 
                    x:Name="fixDock" 
                    Style="{StaticResource CleanToggleButton}"
                    Margin="0,4,40,0" Visibility="Collapsed"
                    VerticalAlignment="Top" HorizontalAlignment="Right">
                    <Image Source="/Images/pin.png" Width="16" Height="16" />
                </ToggleButton>
            </Grid>
            
        </Border>

        <GridSplitter
            x:Name="leftGridSplitter"
            Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Width="4" VerticalAlignment="Stretch">
        </GridSplitter>

      

        <Menu 
            Grid.Column="1" Grid.Row="1" 
            Margin="0,3,0,0" HorizontalAlignment="Right" VerticalAlignment="Top">

            <MenuItem x:Name="ownersMenuItem" Header="{x:Static props:Resources.Factory_owners}" Command="{Binding ShowOwnersListCommand}">
                <MenuItem.Style>
                    <Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Visibility" Value="Collapsed"/>
                             </Trigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
            </MenuItem>

            <Separator Style="{StaticResource SimpleSeparator}" Visibility="{Binding Visibility, ElementName=ownersMenuItem}"/>

            <MenuItem Header="{Binding SigninMenuText}" Command="{Binding SignInCommand}" Margin="0,0,-5,0" >
                <MenuItem.Style>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsMemberSigned}" Value="true">
                                <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
            </MenuItem>
            <MenuItem Margin="0,0,-5,0" Header="{Binding SignedMemberName}">                
                <MenuItem.Items>
                    <MenuItem Header="{x:Static props:Resources.My_profile}" Command="{Binding ShowMyProfileCommand}"/>
                    <MenuItem Header="{x:Static props:Resources.Sign_out}" Command="{Binding SignInCommand}"/>
                    <MenuItem Header="{x:Static props:Resources.Repository_log_settings}" Command="{Binding ShowRepoLogSettingsCommand}"/>
                    <MenuItem Header="{x:Static props:Resources.About}" Command="{Binding ShowAboutDialogCommand}"/>
                    <MenuItem Header="{x:Static props:Resources.Close}" Command="{Binding CloseWindowCommand}"/>
                </MenuItem.Items>
                <MenuItem.Style>
                    <Style  TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsMemberSigned}" Value="false">
                                <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
            </MenuItem>
            <Button Style="{StaticResource MinimizeButton}" Command="{Binding MinimizeWindowCommand}"/>
            <Button Style="{StaticResource CloseButton}" Command="{Binding CloseWindowCommand}" Margin="0,0,5,0"/>
        </Menu>



        <Border Background="Black" Grid.ColumnSpan="2" Grid.Row="0" Grid.RowSpan="2" Opacity="0.5">
            <Border.Style>
                <Style>
                    <Setter Property="Border.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=mainWindow, Path=IsActive}" Value="False">
                            <Setter Property="Border.Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
        </Border>


    </Grid>

        
    
</Window>
 